/**
 * 合同历史回款分析
 * zty
 * 2017-02-20
 */
(function () {
    var serverData = {};
    var	serverTable;
  //查询1
    jQuery(".searchBtn").on('click',function(){//按键ID
    	serverData.key=jQuery("#keyword").val();//文本框的ID
    	serverTable.draw();
    });
    
    //撤消
    jQuery(".cancelBtn").on('click',function(){
    	jQuery("#keyword").val('');//文本框的ID
    	serverData.key='';
    	serverTable.draw();
    });
    jQuery(document).ready(function () {
        serverTable = jQuery('#dataTable').DataTable({
        	"serverSide": true,
        	"ordering": false,
        	"ajax": {
        	"dataType": "json",
        	"type": "post",
        	"cache": false,
        	"url":window.rootPath+ '/ui/contractInfoQuoteDeviceIndex/getpage',
        	"data": function (d) {
        		return $.extend({}, d, serverData);
        		}
        	},
        "columns": [{
			        	data: null,
			            defaultContent: ""
			        },
                    {
                      data: 'supplierCode'//合同号
                  },
                  {
                      data: 'orderUnit'//订货单位
                    	  ,
                          render:function(data,type,full,meta){
                          	if(data == null || data == undefined || data == ""){
          						return data;
          					}else{
          						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
          					}
          				}
                  },
                  {
                      data: 'productModel'//产品型号
                  },
                  {
                      data: 'number'//数量
                  },
                  {
                      data: 'unitPrice'//单价
                  },
                  {
                      data: 'totalSum'//合同总价
                  },
                  {
                      data: 'operator'//经办人
                  },
                  {
                      data: 'productType'//产品类型
                      /*render: function (data, type, full, meta) {
                          if (data)
                              return moment(data).format('YYYY-MM-DD');
                          else{
                              return '';
                          }
                      }*/
                  },
                  {
                	 data: 'orderArea'//订货片区
                  },
                  {
                 	 data: 'projectName'//项目名称
                  },
                  {
                 	 data: 'signedDate',//签订日期
	                 	render: function (data, type, full, meta) {
	                        if (data)
	                            return moment(data).format('YYYY-MM-DD');
	                        else{
	                            return '';
	                        }
	                    }
                  },
                  {
                 	 data: 'scheduleDate',//排产日期
                 	render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY-MM-DD');
                        else{
                            return '';
                        }
                    }
                  },
                  {
                  	 data: 'giveOutDate',//交货日期
                  	render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY-MM-DD');
                        else{
                            return '';
                        }
                    }
                  },
                  {
                   	 data: 'payType'//支付方式
                   		,
                        render:function(data,type,full,meta){
                        	if(data == null || data == undefined || data == ""){
        						return data;
        					}else{
        						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        					}
        				}
                  },
                  {
                  	 data: 'cMotor'//电机
                  		,
                        render:function(data,type,full,meta){
                        	if(data == null || data == undefined || data == ""){
        						return data;
        					}else{
        						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        					}
        				}
                  },
                  {
                  	 data: 'power'//功率
                  		,
                        render:function(data,type,full,meta){
                        	if(data == null || data == undefined || data == ""){
        						return data;
        					}else{
        						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        					}
        				}
                  },
                  {
                  	 data: 'stop'//货物到站
                  		,
                        render:function(data,type,full,meta){
                        	if(data == null || data == undefined || data == ""){
        						return data;
        					}else{
        						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        					}
        				}
                  },
                  {
                  	 data: 'freightCharge'//运费支付
                  		,
                        render:function(data,type,full,meta){
                        	if(data == null || data == undefined || data == ""){
        						return data;
        					}else{
        						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        					}
        				}
                  },
                  {
                  	 data: 'orderAddress'//订货地址
                  		,
                        render:function(data,type,full,meta){
                        	if(data == null || data == undefined || data == ""){
        						return data;
        					}else{
        						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        					}
        				}
                  },
                  {
                  	 data: 'orderDelegate'//订货代表
                  },
                  {
                  	 data: 'orderPhone'//订货电话
                  },
                  {
                  	 data: 'orderZip'//订货邮编
                  },
                  {
                  	 data: 'postUnit'//邮寄单位
                  		,
                        render:function(data,type,full,meta){
                        	if(data == null || data == undefined || data == ""){
        						return data;
        					}else{
        						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        					}
        				}
                  },
                  {
                  	 data: 'postAddress'//邮寄地址
                  		,
                        render:function(data,type,full,meta){
                        	if(data == null || data == undefined || data == ""){
        						return data;
        					}else{
        						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        					}
        				}
                  },
                  {
                    data: 'postDelegate'//邮寄代表
                    	,
                        render:function(data,type,full,meta){
                        	if(data == null || data == undefined || data == ""){
        						return data;
        					}else{
        						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        					}
        				}
                   },
                   {
                   	 data: 'postPhone'//邮寄电话
                   },
                   {
                   	 data: 'postZip'//邮寄邮编
                   },
                   {
                   	 data: 'subDivideType'//细分类型
                   		,
                        render:function(data,type,full,meta){
                        	if(data == null || data == undefined || data == ""){
        						return data;
        					}else{
        						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        					}
        				}
                   },
                   {
                   	 data: 'productName'//产品名称
                   		,
                        render:function(data,type,full,meta){
                        	if(data == null || data == undefined || data == ""){
        						return data;
        					}else{
        						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        					}
        				}
                   },
                   {
                   	 data: 'transMedia'//传输介质
                   		,
                        render:function(data,type,full,meta){
                        	if(data == null || data == undefined || data == ""){
        						return data;
        					}else{
        						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        					}
        				}
                   },
                   {
                   	 data: 'cPumpType'//泵类型
                   		,
                        render:function(data,type,full,meta){
                        	if(data == null || data == undefined || data == ""){
        						return data;
        					}else{
        						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        					}
        				}
                   },
                   {
                   	 data: 'nPumpNum'//泵数量
                   },
                   {
                   	 data: 'nPumpTotalPrice'//泵总价
                   },
                   {
                   	 data: 'nIsSpecial'//特殊泵
                   },
                   {
                   	 data: 'flux'//流量
                   		,
                        render:function(data,type,full,meta){
                        	if(data == null || data == undefined || data == ""){
        						return data;
        					}else{
        						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
        					}
        				}
                   },
                   {
                     	 data: 'pumpLift'//扬程
                     		,
                            render:function(data,type,full,meta){
                            	if(data == null || data == undefined || data == ""){
            						return data;
            					}else{
            						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
            					}
            				}
                    },
                    {
                    	 data: 'temperature'//湿度
                    		 ,
                             render:function(data,type,full,meta){
                             	if(data == null || data == undefined || data == ""){
             						return data;
             					}else{
             						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
             					}
             				}
                    },
                    {
                    	 data: 'viscosity'//粘度
                    		 ,
                             render:function(data,type,full,meta){
                             	if(data == null || data == undefined || data == ""){
             						return data;
             					}else{
             						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
             					}
             				}
                    },
                    {
                    	 data: 'proportion'//比重
                    		 ,
                             render:function(data,type,full,meta){
                             	if(data == null || data == undefined || data == ""){
             						return data;
             					}else{
             						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
             					}
             				}
                    },
                    {
                    	 data: 'inPressure'//入口压力
                    		 ,
                             render:function(data,type,full,meta){
                             	if(data == null || data == undefined || data == ""){
             						return data;
             					}else{
             						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
             					}
             				}
                    },
                    {
                    	 data: 'cOutletPressure'//出口压力
                    		 ,
                             render:function(data,type,full,meta){
                             	if(data == null || data == undefined || data == ""){
             						return data;
             					}else{
             						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
             					}
             				}
                    },
                    {
                    	 data: 'flowMaterial'//过流材质
                    		 ,
                             render:function(data,type,full,meta){
                             	if(data == null || data == undefined || data == ""){
             						return data;
             					}else{
             						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
             					}
             				}
                    },
                    {
                    	 data: 'sEffectiveNPSHA'//有效气蚀余量
                    		 ,
                             render:function(data,type,full,meta){
                             	if(data == null || data == undefined || data == ""){
             						return data;
             					}else{
             						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
             					}
             				}
                    },
                    {
                    	 data: 'mustMPSHA'//必须气蚀余量
                    		 ,
                             render:function(data,type,full,meta){
                             	if(data == null || data == undefined || data == ""){
             						return data;
             					}else{
             						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
             					}
             				}
                    },
                    {
                    	 data: 'cUnit'//使用单位
                    		 ,
                             render:function(data,type,full,meta){
                             	if(data == null || data == undefined || data == ""){
             						return data;
             					}else{
             						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
             					}
             				}
                    },
                    {
                    	 data: 'cBitNumber'//位号
                    		 ,
                             render:function(data,type,full,meta){
                             	if(data == null || data == undefined || data == ""){
             						return data;
             					}else{
             						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
             					}
             				}
                    }
                    ,
                    {
                    	 data: 'industryInfo'//行业
                    		 ,
                             render:function(data,type,full,meta){
                             	if(data == null || data == undefined || data == ""){
             						return data;
             					}else{
             						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
             					}
             				}
                    }
                    ,
                    {
                    	 data: 'areaName'//片区
                    }
                    ,
                    {
                    	 data: 'cMemo'//备注
                    		 ,
                             render:function(data,type,full,meta){
                             	if(data == null || data == undefined || data == ""){
             						return data;
             					}else{
             						return (data.length > 10) ? '<font title="'+data+'">'+data.substring(0,10)+'...'+'</font>' : data;
             					}
             				}
                    }
                    ],
                  "drawCallback": function (oSettings) {
                      var k = 0;
                      var total = oSettings.aiDisplay.length + oSettings._iDisplayStart;

                      for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
                          $('td:eq(0)', oSettings.aoData[oSettings.aiDisplay[k]].nTr).text(i + 1);
                          k++;
                      }
                    
                  }
        });
    });
        
	    
})();


jQuery('.importAll').on("click",function() {
		var key = jQuery("#keyword").val();
	   var url=window.rootPath+ "/ui/contractInfoQuoteDeviceIndex/export?key="+key;
	   window.location = url;
});